import {addShareApply, queryMyFiles, queryShareFiles,getPreviewLinkPath,queryGroupList} from '@/services/workspace';

export default {
  namespace: 'publicModel',

  state: {
    // 列表数据
    data: {
      dataList: [],
      pageNum: 0,
      pageSize: 0,
      totalCount: 0,
    },
    queryForm: {},

  },

  effects: {
    * queryGroupList({payload,callback}, {call, put}) {
      const response = yield call(queryGroupList, payload);
      if (callback) callback(response);
    },
    * queryMyFiles({payload}, {call, put}) {
      const response = yield call(queryMyFiles, payload);
      if(response&&response.result=='ok'){

      yield put({
        type: 'save',
        payload: response,
      });
      }
    },
    //申请下载
    * addShareApply({payload, callback}, {call, put}) {
      const response = yield call(addShareApply, payload);
      if (callback) callback(response);
    },
    * getPreviewLinkPath({payload, callback}, {call, put}) {
      const response = yield call(getPreviewLinkPath, payload);
      if (callback) callback(response);
    },

  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data,
      };
    },
  },
};
